package com.villaday.idf.adapter;

import android.content.Context;
import android.view.View;

import com.villaday.idf.R;
import com.villaday.idf.base.AbsRecyclerViewAdapter;
import com.villaday.idf.base.OnAdapterCallbackListener;
import com.villaday.idf.model.RecommendEntity;
import com.villaday.idf.model.RefreshtokenEntity;
import com.villaday.idf.model.VipsMemberActions;
import com.villaday.idf.util.SharedPreferencesUtil;

/**
 * Vip客户行为列表适配器，单独使用
 */

public class CustomerBehaviorAdapter extends AbsRecyclerViewAdapter<VipsMemberActions.BodyBean.ListBean> {
    private OnAdapterCallbackListener onAdapterCallbackListener;
    private View.OnClickListener onClickListener;
    private final String roleType;

    public CustomerBehaviorAdapter(Context context, OnAdapterCallbackListener onAdapterCallbackListener) {
        super(context, R.layout.recyclerview_customer_behavior, R.layout.item_page_loading,
                R.layout.item_page_bottom);
        this.onAdapterCallbackListener = onAdapterCallbackListener;
        RefreshtokenEntity.BodyBean roleInfo =
                SharedPreferencesUtil.getRoleInfo(context);
        roleType = roleInfo.getMember().getType();

    }

    @Override
    public int getItemType(VipsMemberActions.BodyBean.ListBean d) {
        return d.getMyType();
    }

    @Override
    public void onBindHolder(AbsRecyclerViewAdapter.RecyclerViewHolder holder, VipsMemberActions.BodyBean.ListBean d, int position) {
        switch (d.getMyType()) {

            case 0: {
                holder.bindSimpleDraweeView(R.id.sdv_userHead, d.getHeaderUrl())
                        .bindTextView(R.id.tv_name, d.getNickName())
                        .bindTextView(R.id.tv_browse_content, d.getAction().getDesc())
                        .setViewVisible(R.id.tv_last_browse, View.GONE)
                        .bindTextView(R.id.tv_browse_time, d.getAction().getActionTime());
            }
            break;

            case 1: {
                onAdapterCallbackListener.onCallback();
            }
            break;


        }
    }
}
